package scu.maqiang.fes;

import scu.maqiang.mesh.Mesh;
import scu.maqiang.mesh.ScalarCFunc;
import scu.maqiang.mesh.ScalarFunc;
import scu.maqiang.numeric.*;

public class FES3T3S1 extends FES {

    public FES3T3S1(Mesh mesh) {
        super(mesh, 1);
    }

    public static void elementStiff(double[][] xy, double[][] kxx, BVPType tp, double[][] eleMatrix) {
        double[][] grad = new double[3][2];
        double area = CG.gradient2DT3(xy, grad);
        double[] x = MVO.col(xy, 0);
        double Af;
        double[][] temp;
        switch (tp) {
            case COMMON:
                Af = area * MVO.average(kxx[0]);
                for (int i = 0; i < 3; i++) {
                    for (int j = 0; j < 3; j++) {
                        eleMatrix[i][j] = (grad[i][0] * grad[j][0] + grad[i][1] * grad[j][1]) * Af;
                    }
                }
                break;
            default:
                throw new IllegalArgumentException("Wrong BVPType!");
        }
        // System.out.println(MVO.toString(kxx[0]));
        // System.out.println(Arrays.toString(kxx[0]));
        // System.out.println(MVO.toString(eleMatrix));
    }

    public void assembleHeatMass(ScalarFunc[] coefFunc, double[] param, BVPType tp, SRMatrix A) {
        assembleGlobalMatrix(coefFunc, param, FES2T31::elementMass, tp, A);
    }

    public void assembleHeatMass(double[] constCoef, BVPType tp, SRMatrix A) {
        assembleGlobalMatrix(constCoef, FES2T31::elementMass, tp, A);
    }

    public void assembleHeatMass(double[] constCoef, BVPType tp, SRMatrix A, int... label) {
        assembleGlobalMatrix(constCoef, FES2T31::elementMass, tp, A, label);
    }

    public void assembleHeatMass(double[][] vecCoef, BVPType tp, SRMatrix A) {
        assembleGlobalMatrix(vecCoef, FES2T31::elementMass, tp, A);
    }

    public void assembleHeatMass(ScalarCFunc[] coefCFunc, Complex[] param, BVPType tp, SCMatrix A) {
        assembleGlobalMatrix(coefCFunc, param, FES2T31::elementCMass, tp, A);
    }

    public void assembleHeatMass(Complex[] constCCoef, BVPType tp, SCMatrix A) {
        assembleGlobalMatrix(constCCoef, FES2T31::elementCMass, tp, A);
    }

    public void assembleHeatMass(Complex[][] vecCCoef, BVPType tp, SCMatrix A) {
        assembleGlobalMatrix(vecCCoef, FES2T31::elementCMass, tp, A);
    }

}
